<?php
/**
 * @Author: rocky
 * Date: 2019/9/27
 * Time: 10:25
 */

namespace app\shop\controller\api\v1;

use app\common\controller\BaseApiController;
use app\common\facade\Token;
use app\common\model\ShopAnswer;
use app\common\model\ShopOpinion;
use app\shop\validate\AnswerValidate;

class Opinion extends BaseApiController
{
    /*
     * 列表
     */
    public function getIndex()
    {
        $data = ShopOpinion::field('title,content')->where('status',1)->all();
        $this->successCode($data);
    }

    /*
     * 提交问题
     */
    public function postInfo()
    {
        $post = (new AnswerValidate())->goCheck();
        $post['uid'] = Token::id();
        $res = ShopAnswer::create($post);
        if(!$res){
            $this->errorCode('100','提交失败');
        }
        $this->successCode();
    }
}